/**
 *  @file SDLFader.h
 *
 *  @date 28-nov-2009
 *  @author Ives van der Flaas
 */

#ifndef SDLFADER_H_
#define SDLFADER_H_

#include "SDLStaticRepresentation.h"
#include "vector2.h"
#include "SDLColor.h"

namespace si_sdl
{
/**
 * FADE_TO_COLOR means the image will start out looking normal and then slowly go to the color you
 * entered. FADE_FROM_COLOR means you start out the color you entered and then slowly go to
 * the original.
 */
enum FadeType { FADE_TO_COLOR, FADE_FROM_COLOR };
/**
 * A rectangular object that will fade either from or to a color.
 */
class SDLFader: public si_sdl::SDLStaticRepresentation
{
public:
	/**
	 *
	 * @param c Color we'll fade to or from (default: whole screen will fade)
	 * @param type either FADE_TO_COLOR to fade to a color or FADE_FROM_COLOR to fade from a color
	 * @param speed Speed in percent / second the image will fade
	 * @return
	 */
	SDLFader(Color c, FadeType type, double speed): fPos(0,0), fSize(0,0), fColor(c) { reset(c, type, speed); }
	void reset(Color c, FadeType type, double speed);

	void setRect(si::Vector2 pos, si::Vector2 size);
	virtual void draw();
	virtual void update(double time);

	virtual ~SDLFader();

private:
	FadeType fType;
	double fCurrentOpacity;
	double fSpeed;
	si::Vector2 fPos;
	si::Vector2 fSize;
	Color fColor;

};

}

#endif /* SDLFADER_H_ */
